package br.uvv.Service;

import java.io.Serializable;
import java.util.List;

import org.primefaces.model.SortOrder;

import br.uvv.Dao.AtorDAO;
import br.uvv.Model.Ator;
import br.uvv.Util.DAOException;
import br.uvv.Util.RNException;

public class AtorService implements Serializable {

	private static final long serialVersionUID = 2310091665586839549L;
	
	private AtorDAO atorDao = new AtorDAO();

	public List<Ator> listarAtor() throws RNException {
		try {
			return atorDao.listar();
		} catch (DAOException e) {
			throw new RNException(e);
		}
	}
	
	public List<Ator> listarAtor(int first, int pageSize, String sortField, SortOrder sortOrder, String nome) throws RNException {
		try {
			return atorDao.listar(first, pageSize, sortField, sortOrder, nome);
		} catch (DAOException e) {
			throw new RNException(e);
		}
	}
	
	public Integer countAtor(String nome) throws RNException{
		try {
			return atorDao.count(nome);
		} catch (DAOException e){
			throw new RNException(e);
		}
	}
	

	public Ator selecionarAtor(Long id) throws RNException{
		try {
			return atorDao.selecionar(id);
		} catch (DAOException e){
			throw new RNException(e);
		}
	}

	public void removerAtor(Ator atorInstance) throws RNException {
		try {
			atorDao.remover(atorInstance);
		} catch (DAOException e){
			throw new RNException(e);
		}
	}

	public void atualizarAtor(Ator atorInstance) throws RNException {
		try {
			atorDao.salvar(atorInstance);
		} catch (DAOException e){
			throw new RNException(e);
		}
	}

	public void salvarAtor(Ator atorInstance) throws RNException {
		try {
			atorDao.salvar(atorInstance);
		} catch (DAOException e){
			throw new RNException(e);
		}
	}	
}